﻿using System;
using Microsoft.Practices.ServiceLocation;

namespace Caramel.Cqrs
{
	public static class CommandExecutor
	{
		public static void Execute<TCommand>(TCommand command)
			where TCommand : class, ICommand
		{
			foreach (var executor in ServiceLocator.Current.GetAllInstances<ICommandExecutor<TCommand>>())
			{
				executor.Execute(command);
			}
		}
	}
}
